package com.atguigu.fink.chapter01.sql;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @Author lzc
 * @Date 2022/11/28 09:06
 */
public class Flink04_SQL_Kafka_Upsert_2 {
    public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port", 4000);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(1);
        
        StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
        
        tEnv.executeSql("create table sensor_t(" +
                            "id string, " +
                            "vc_sum int " +
                            ")with(" +
                            " 'connector' = 'kafka', " +
                            "  'topic' = 's3', " +
                            "  'properties.bootstrap.servers' = 'hadoop162:9092', " +
                            "  'format' = 'json',  " +
                            "  'scan.startup.mode' = 'earliest-offset' " +
                            ")");
        
        tEnv.sqlQuery("select * from sensor_t").execute().print();
    
        
    
    
    }
}
